<template>
    <div>
        <Modal :title="postTitle" v-model="postModalVisible" :mask-closable='false' @on-cancel="cancel" :width="1140" :styles="{top: '90px'}" :footer-hide="true">
            <div>
                <rui-page :defines="defines">
                    <rui-table :defineId="'postInfo'"
                               :select="false"
                               @loadDatas="queryPostInfo"
                               ref="postInfoTable">
                    </rui-table>
                </rui-page>
            </div>
        </Modal>
    </div>
</template>
<script>
    let postInfo = [
        {
            key: 'userName',
            title: '岗位异动人',
            align: 'center',
        },
        {
            key: "postChangeStatus",
            title: "岗位异动状态",
            align: 'center',
            render: (h, params) => {
                let enable = '';
                let color = '';
                let arr = params.row.postChangeStatus;
                if(arr==="0"){
                    enable = '离岗';
                }else if (arr==="1") {
                    enable = '在岗';
                }else {
                    enable = '';
                }
                return h('div', {
                    domProps: {
                        innerHTML: enable,
                    },
                    style: {
                        color: color
                    }
                })
            }
        },
        {
            key: "changeRemarks",
            title: "岗位异动备注",
            align: 'center',
        },
        {
            key: 'createBy',
            title: '操作人',
            align: 'center',
        },
        {
            key: 'createTime',
            title: '操作时间',
            align: 'center',
        }
    ]
    import {queryPostChangeLog} from "@/projects/afs-core-business/api/afs-case/parameter-rules/group";
    export default {
        name: "postRecord",
        id:"",
        data() {
            return{
                postTitle:"岗位异动日志",
                postModalVisible:false,
                searchForm:{
                    pageNumber: 1,
                    pageSize: 10,
                    userId:""
                },
            }
        },
        methods:{
            parentMsg: function (msg) {
                if(msg!==""){
                    this.postModalVisible = true;
                    this.searchForm.pageNumber = 1;
                    this.searchForm.pageSize = 10;
                    this.searchForm.userId = msg;
                    this.getList();
                }
            },
            queryPostInfo(pageNumber, pageSize){
                this.searchForm.pageNumber = pageNumber;
                this.searchForm.pageSize = pageSize;
                queryPostChangeLog(this.searchForm).then(res=>{
                    if(res.code === "0000"){
                        let {records, total} = res.data;
                        this.$refs.postInfoTable.updateTableData(records, total);
                    }
                })
            },
            getList(){
                queryPostChangeLog(this.searchForm).then(res=>{
                    if(res.code === "0000"){
                        let {records, total} = res.data;
                        this.$refs.postInfoTable.updateTableData(records, total);
                    }
                })
            },
            cancel(){
                this.$refs.postInfoTable.resetData();
            }
        },
        computed: {
            defines() {
                return [
                    {
                        id: 'postInfo',
                        fields: postInfo
                    }
                ]
            }
        }
    }
</script>
